<#include '/admin/header.html' >

</style>
<div class="main">

	<div class="shadowBoxWhite whiteBox">
		<table cellpadding="5" width="100%">
			<tr>
				<th class="title" colspan="4">高级搜索</th>
			</tr>
			<tr>
				<td width="70" >
					<select id="year">
					</select>
				</td>
				<td width="70" >
					<select id="month">
					</select>
				</td>
				<td width="200" style="text-align: center;">
					<a id="search_data" class="button blueButton"  href="javascript:void(0);">开始搜索</a>
				</td>
				<td width="70%" >
				</td>
			</tr>
		</table>
	</div>
	<div class="clear height10"></div>
	<div class="shadowBoxWhite whiteBox">
		<table cellpadding="5" width="100%">
			<tr>
				<th class="title" colspan="4">销售收入总览</th>
			</tr>
			<tr>
				<th width="50px;"></th>
				<td style="text-align: left;">
					<div class="deliveryexp price">
						<span>收款金额:&nbsp;&nbsp;<span id="receivables" >${receivables!0}</span></span>
						<span>退款金额:&nbsp;&nbsp;<span id="refund" >${refund!0}</span></span>
						<span>实收金额:&nbsp;&nbsp;<span id="paid" >${paid!0}</span></span>
					</div>
				</td>
				
			</tr>
		</table>
	</div>
	
	<div class="clear height10"></div>
	<div class="shadowBoxWhite tableDiv">
		<table class="easyui-datagrid" 
			data-options="url:'${ctx}/shop/admin/salesStatis/sale-income-json.do',pageList: [5,10,15,20],pageSize:${pageSize},fitColumns:'true',queryParams:{'complete':'${complete!''}'}"
			pagination="true" width="width" id="salesdata" sortName="order_id" sortOrder="desc">
			<thead>
				<tr>
					<!-- <th data-options="field:'order_id',checkbox:true,width:100"></th> -->
					<th data-options="field:'name',width:150" >商品名称</th>
					<th data-options="field:'t_num',width:100,sortable:'true'" >商品数量</th>
					<th data-options="field:'price',width:100,sortable:'true'" >商品单价</th>
					<th data-options="field:'t_price',width:100">订单金额</th>
				</tr>
			</thead>
		</table>
	</div>
</div>

<input type="hidden" id="this_type" value="1" >


<script type="text/javascript">

$(function() {
	var currentYear = new Date().getFullYear();
	var historyYear = currentYear-10;
	
	var currentmonth = new Date().getMonth();
	currentmonth+=1;
	for(var i=0;i<20;i++){
		if(currentYear==historyYear){
			$("#year").append("<option value='"+historyYear+"' selected='selected' >"+historyYear+"年</option>" );
		}else{
			$("#year").append("<option value='"+historyYear+"' >"+historyYear+"年</option>" );
		}
		historyYear++;
	}
	
	for(var i=1;i<=12;i++){
		if(currentmonth==i){
			$("#month").append("<option value='"+i+"' selected='selected' >"+i+"月</option>" );
		}else{
			$("#month").append("<option value='"+i+"' >"+i+"月</option>" );
		}
	}
	
	$("#search_data").click(function(){
		var year = $("#year :selected").val();
		var month = $("#month :selected").val();
		
		$.ajax({
			url : "${ctx}/shop/admin/salesStatis/sale-income-totle-json.do?year="+year+"&month="+month,
			type : "POST",
			dataType : 'json',
			success : function(result) {
				if (result.result == 1) {
					$("#receivables").html(result.data.receivables);
					$("#refund").html(result.data.refund);
					$("#paid").html(result.data.paid);
				}
				if (result.result == 0) {
					$.Loading.error(result.message);
				}
			},
			error : function(e) {
				$.Loading.error("出现错误 ，请重试");
			}
		});
		
		$("#salesdata").datagrid('load', {
			year:year,
			month:month,
			page:1
	    }); 
		
	})
		
});


function formatDate(value,row,index){
	if(value==null||value==0){
		return "";
	}
	else{
		return getFormatDateByLong(value, "yyyy-MM-dd");
	}
}


</script>

<#include '/admin/footer.html' >